import type { RouteMeta, RouteRecordRaw } from 'vue-router'

export function buildMeta(data: RouteMeta = {}): RouteMeta {
  return {
    ...data,
    module: 'APPLICATION',
  }
}

export default {
  path: '/applications',
  meta: buildMeta(),
  component: () => import('@/components/layout/DefaultLayout.vue'),
  children: [
    {
      path: '',
      meta: buildMeta({ title: '应用管理' }),
      children: [
        {
          path: '',
          name: 'Applications',
          component: () => import('@/views/applications/manage/apps'),
          meta: buildMeta({ title: '应用列表' }),
        },
        {
          path: 'config/:appid',
          name: 'ApplicationsConfig',
          component: () => import('@/views/applications/manage/config'),
          meta: buildMeta({
            title: '配置资源',
            activeMenu: 'Applications',
            breadcrumbs: [{ title: '应用列表', to: { name: 'Applications' } }],
          }),
        },
      ],
    },
    {
      path: 'resource',
      name: 'ResourceStatistics',
      children: [
        {
          path: 'cloud-computing',
          name: 'ResourceStatisticsWithCloudComputing',
          component: () =>
            import('@/views/applications/statistics/cloud-computing'),
          meta: buildMeta({ title: '云计算资源' }),
        },
        {
          path: 'cdn',
          name: 'ResourceStatisticsWithCloudCdn',
          component: () => import('@/views/applications/statistics/cdn'),
          meta: buildMeta({ title: 'CDN 资源' }),
        },
      ],
    },
  ],
} satisfies RouteRecordRaw
